<%@page import="edcom.server.*"%>
<%@page import="edcom.client.*" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%

//invoke AddStudentView 
AddStudentView view = new AddStudentView();
String[] errorMessages, inputs = new String[8];

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>requestAddStudent</title>
</head>
<body>

<h1>TESTBENCH</h1>
<h3>requestAddStudent()</h3>
<a href="index.jsp">RETURN</a>
<br /><br />

(DevTeam, be sure to clear the tables before accessing this page.)

<br/><br/>
<b>Run #1 :: successful insert</b>
<% view = new AddStudentView(); 
errorMessages = view.requestAddStudent(
		inputs[0] = "Lee Masamune", 
		inputs[1] = "2008-07612", 
		inputs[2] = "koffeeaddikt",
		inputs[3] = "password", 
		inputs[4] = "leemasamune@gmail.com", 
		inputs[5] = "BS Applied Psionics, maj. Psi Programming");
out.println("<br/>\n<table border=\'1\'>");
for(int x = 0; x < errorMessages.length - 2; x++)
{
	out.print("<tr><td>" + inputs[x] + "</td><td>");
	if((errorMessages[x] == null) || (errorMessages[x] == ""))
		out.print("{no error}");
	else
		out.print(errorMessages[x]);
	out.println("</td></tr>");
} 
out.println("<tr><td colspan=\'2\'>SQL Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.sqlStatus]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.sqlStatus]);
out.println("</td></tr>");
out.println("<tr><td colspan=\'2\'>Other Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.generalError]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.generalError]);
out.println("</td></tr>");
out.println("</table>\n<br/><br/>");
%>

<b>Run #2 :: fail insert</b><br/>
reason: UNIQUE fields (student number, email, username) reinserted
<% view = new AddStudentView();
errorMessages = view.requestAddStudent(
		inputs[0] = "Lee Masamune", 
		inputs[1] = "2008-07612", 
		inputs[2] = "koffeeaddikt",
		inputs[3] = "password", 
		inputs[4] = "leemasamune@gmail.com", 
		inputs[5] = "BS Applied Psionics, maj. Psi Programming");
out.println("<br/>\n<table border=\'1\'>");
for(int x = 0; x < errorMessages.length - 2; x++)
{
	out.print("<tr><td>" + inputs[x] + "</td><td>");
	if((errorMessages[x] == null) || (errorMessages[x] == ""))
		out.print("{no error}");
	else
		out.print(errorMessages[x]);
	out.println("</td></tr>");
} 
out.println("<tr><td colspan=\'2\'>SQL Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.sqlStatus]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.sqlStatus]);
out.println("</td></tr>");
out.println("<tr><td colspan=\'2\'>Other Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.generalError]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.generalError]);
out.println("</td></tr>");
out.println("</table>\n<br/><br/>");
%>

<b>Run #3 :: fail insert</b><br/>
reason: field(s) empty
<% view = new AddStudentView();
errorMessages = view.requestAddStudent(
		inputs[0] = "", 
		inputs[1] = "", 
		inputs[2] = "",
		inputs[3] = "", 
		inputs[4] = "", 
		inputs[5] = "");
out.println("<br/>\n<table border=\'1\'>");
for(int x = 0; x < errorMessages.length - 2; x++)
{
	out.print("<tr><td>" + inputs[x] + "</td><td>");
	if((errorMessages[x] == null) || (errorMessages[x] == ""))
		out.print("{no error}");
	else
		out.print(errorMessages[x]);
	out.println("</td></tr>");
} 
out.println("<tr><td colspan=\'2\'>SQL Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.sqlStatus]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.sqlStatus]);
out.println("</td></tr>");
out.println("<tr><td colspan=\'2\'>Other Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.generalError]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.generalError]);
out.println("</td></tr>");
out.println("</table>\n<br/><br/>");
%>

<b>Run #4 :: fail insert</b><br/>
reasons: name and course-major contains numeric character()s<br/>
malformed student number and email address
<% view = new AddStudentView();
errorMessages = view.requestAddStudent(
		inputs[0] = "Ka5umi Sta3dtl3r", 
		inputs[1] = "200821670", 
		inputs[2] = "december10_1991",
		inputs[3] = "annihilium", 
		inputs[4] = "kasumistaedtler@gmail", 
		inputs[5] = "BS-65535");
out.println("<br/>\n<table border=\'1\'>");
for(int x = 0; x < errorMessages.length - 2; x++)
{
	out.print("<tr><td>" + inputs[x] + "</td><td>");
	if((errorMessages[x] == null) || (errorMessages[x] == ""))
		out.print("{no error}");
	else
		out.print(errorMessages[x]);
	out.println("</td></tr>");
} 
out.println("<tr><td colspan=\'2\'>SQL Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.sqlStatus]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.sqlStatus]);
out.println("</td></tr>");
out.println("<tr><td colspan=\'2\'>Other Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.generalError]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.generalError]);
out.println("</td></tr>");
out.println("</table>\n<br/><br/>");
%>

<b>Run #5 :: fail insert</b><br/>
reason: malformed student number and email address
<% view = new AddStudentView();
errorMessages = view.requestAddStudent(
		inputs[0] = "Kasumi Staedtler", 
		inputs[1] = "batcheight", 
		inputs[2] = "december10_1991",
		inputs[3] = "annihilium", 
		inputs[4] = "kasumistaedtlergmail.com", 
		inputs[5] = "BS Applied Psionics, maj. Meta-Layers");
out.println("<br/>\n<table border=\'1\'>");
for(int x = 0; x < errorMessages.length - 2; x++)
{
	out.print("<tr><td>" + inputs[x] + "</td><td>");
	if((errorMessages[x] == null) || (errorMessages[x] == ""))
		out.print("{no error}");
	else
		out.print(errorMessages[x]);
	out.println("</td></tr>");
} 
out.println("<tr><td colspan=\'2\'>SQL Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.sqlStatus]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.sqlStatus]);
out.println("</td></tr>");
out.println("<tr><td colspan=\'2\'>Other Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.generalError]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.generalError]);
out.println("</td></tr>");
out.println("</table>\n<br/><br/>");
%>

<b>Run #6 :: fail insert</b><br/>
reason: malformed email address
<% view = new AddStudentView();
errorMessages = view.requestAddStudent(
		inputs[0] = "Kasumi Staedtler", 
		inputs[1] = "2008-21670", 
		inputs[2] = "december10_1991",
		inputs[3] = "annihilium", 
		inputs[4] = "kasumistaedtler65535", 
		inputs[5] = "BS Applied Psionics, maj. Meta-Layers");
out.println("<br/>\n<table border=\'1\'>");
for(int x = 0; x < errorMessages.length - 2; x++)
{
	out.print("<tr><td>" + inputs[x] + "</td><td>");
	if((errorMessages[x] == null) || (errorMessages[x] == ""))
		out.print("{no error}");
	else
		out.print(errorMessages[x]);
	out.println("</td></tr>");
} 
out.println("<tr><td colspan=\'2\'>SQL Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.sqlStatus]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.sqlStatus]);
out.println("</td></tr>");
out.println("<tr><td colspan=\'2\'>Other Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.generalError]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.generalError]);
out.println("</td></tr>");
out.println("</table>\n<br/><br/>");
%>

<b>Run #7 :: fail insert</b><br/>
reason: malformed email address
<% view = new AddStudentView();
errorMessages = view.requestAddStudent(
		inputs[0] = "Kasumi Staedtler", 
		inputs[1] = "2008-21670", 
		inputs[2] = "december10_1991",
		inputs[3] = "annihilium", 
		inputs[4] = "kasumistaedtler @gmail.com", 
		inputs[5] = "BS Applied Psionics, maj. Meta-Layers");
out.println("<br/>\n<table border=\'1\'>");
for(int x = 0; x < errorMessages.length - 2; x++)
{
	out.print("<tr><td>" + inputs[x] + "</td><td>");
	if((errorMessages[x] == null) || (errorMessages[x] == ""))
		out.print("{no error}");
	else
		out.print(errorMessages[x]);
	out.println("</td></tr>");
} 
out.println("<tr><td colspan=\'2\'>SQL Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.sqlStatus]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.sqlStatus]);
out.println("</td></tr>");
out.println("<tr><td colspan=\'2\'>Other Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.generalError]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.generalError]);
out.println("</td></tr>");
out.println("</table>\n<br/><br/>");
%>
<!-- 
<b>Run #8 :: fail insert</b><br/>
reason: email does not exist (?)
<% /* 
view = new AddStudentView();
errorMessages = view.requestAddStudent(
		inputs[0] = "Kasumi Staedtler", 
		inputs[1] = "2008-21670", 
		inputs[2] = "december10_1991",
		inputs[3] = "annihilium", 
		inputs[4] = "kasumistaedtler@gmail.com", 
		inputs[5] = "BS Applied Psionics, maj. Meta-Layers");
out.println("<br/>\n<table border=\'1\'>"); 
for(int x = 0; x < errorMessages.length - 2; x++)
{
	out.print("<tr><td>" + inputs[x] + "</td><td>");
	if((errorMessages[x] == null) || (errorMessages[x] == ""))
		out.print("{no error}");
	else
		out.print(errorMessages[x]);
	out.println("</td></tr>");
} 
out.println("<tr><td colspan=\'2\'>SQL Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.sqlStatus]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.sqlStatus]);
out.println("</td></tr>");
out.println("<tr><td colspan=\'2\'>Other Errors&gt;  ");
if((errorMessages[Student.sqlStatus] == null) || 
		(errorMessages[Student.generalError]== ""))
	out.print("{no error}");
else
	out.print(errorMessages[Student.generalError]);
out.println("</td></tr>");
out.println("</table>\n<br/><br/>");// */
%>-->
</body>
</html>